<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 200px;
            background-color: pink;
            position: absolute;
            display: none;
        }
        
        ul {
            list-style: none;
            width: 100px;
            height: 100px;
        }
        
        li {
            width: 50px;
            height: 20px;
            background-color: red;
            line-height: 20px;
            font-size: 10px;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li>1.啊啊啊</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ul>
    </div>
    <script>
        // 获取框
        var obox = document.querySelector(".box");

        // 鼠标右键
        document.oncontextmenu = function(e) {
            var x = e.clientX;
            var y = e.clientY;
            console.log(x, y);
            // 点击右键出现框
            obox.style.display = "block";
            obox.style.left = x + "px";
            obox.style.top = y + "px";
            // 隐藏默认的电脑右键框
            e.preventDefault();
        };
        // 单击隐藏右键框
        document.onclick = function() {
            obox.style.display = "none";
        };
    </script>
</body>

</html>